https://leetcode.cn/problems/maximum-width-of-binary-tree/description/
class Solution {
public:
    int widthOfBinaryTree(TreeNode* root) {
        vector<pair<TreeNode*,size_t >> q;
        q.push_back({root,1});
        size_t  ret=0;
        while(!q.empty())
        {
            auto&[x1,y1]=q[0];
            auto&[x2,y2]=q.back();
            ret=max(y2-y1+1,ret);

            //更新新结点
            vector<pair<TreeNode*,size_t >> tmp;
            for(auto &[x,y]:q)
            {
                if(x->left) tmp.push_back({x->left,y*2});
                if(x->right) tmp.push_back({x->right,y*2+1});
            }
            q=tmp;
        }
        return ret;
    }
};




